package com.sxt;

import java.awt.*;

//创建一个背景类添加各类素材图片,启动项中只需引用方法名即可
public class Bg {
    //关卡数
    static int level = 1;
    //目标得分
    int goal = level*5;
    //总分
    static int count = 0;

    //药水数量
    static int waterNum = 999;
    //药水状态,默认False，True表示正在使用
    static boolean waterFlag = false;

    //载入图片
    Image bj = Toolkit.getDefaultToolkit().getImage("image/bj.jpg");
    Image bj1 = Toolkit.getDefaultToolkit().getImage("image/bj1.jpg");
    Image peo = Toolkit.getDefaultToolkit().getImage("image/peo.png");
    Image water = Toolkit.getDefaultToolkit().getImage("image/water.png");

    //编写绘制方法，传入画笔
    void painSelf(Graphics g) {
        g.drawImage(bj, 0, 0, null);
        g.drawImage(bj1, 0, 0, null);
        g.drawImage(peo, 500, 65, null);
        drawWord(g,30,Color.BLACK,"积分"+count,30,90);

        //绘制药水
        g.drawImage(water, 600, 50, null);
        drawWord(g,30,Color.BLACK," * "+waterNum,650,80);

        //关卡数
        drawWord(g,20,Color.BLACK,"第"+level+"关",30,60);
        //目标分数
        drawWord(g,30,Color.BLACK,"目标积分"+goal,200,90);
    }

    //因为经常要用到这三行来打印字符串，所以在此封装为一个公共类
    //公共的 静态的  无返回值
    public static void drawWord(Graphics g, int size ,Color color ,String str,int x, int y ) {
        g.setColor(color);
        g.setFont(new Font("仿宋", Font.BOLD, size));
        g.drawString(str,x,y);
    }
}
